package org.freez4.spring.dependency.inject;

import org.freez4.spring.dependency.inject.domain.UserHolder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * XML Set注入Demo。
 *
 * @author 阿坤同学
 * @date 2023/12/10 18:28
 */
public class XmlDependencySetterInjectDemo {

    private static final Logger logger = Logger.getLogger(XmlDependencySetterInjectDemo.class.getName());

    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(beanFactory);

        String location = "classpath:/META-INF/dependency-setter-inject.xml";
        xmlReader.loadBeanDefinitions(location);

        UserHolder userHolder = beanFactory.getBean(UserHolder.class);

        logger.log(Level.INFO, () -> "通过XML方式setter注入User对象Demo: " + userHolder);
    }


}